{
  "properties" : { },
  "id" : "e34d363462d041a1b42d7866df470c31",
  "script" : null,
  "groupId" : "5b4c0f1fcedc4bfbbf84bb3791e01399",
  "name" : "修改告警规则",
  "createTime" : 1727070931869,
  "updateTime" : 1726797854587,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "update",
  "method" : "POST",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "{\n    \"expression\": \"%3E5%26%26%3C8\",\n    \"expressionType\": \"num\",\n    \"id\": \"100003\",\n    \"level\": \"5\",\n    \"ruleMetricId\": \"99998\",\n    \"ruleName\": \"内存使用率高\",\n    \"suppressInterval\": \"300\",\n    \"templateContent\": \"内存使用率超过v%\",\n    \"unit\": \"\"\n}",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": 1\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }
}
================================
import java.net.URLDecoder;
import redis

sql = """ 
        select met.code from alarm_rule ru
        left join alarm_metric met on met.id = ru.rule_metric_id
        where ru.id = #{body.id} 
    """
expression = URLDecoder.decode(body.expression, "UTF-8")
metric = db.selectOne(sql)
if (metric != null) {
    redis.delete("ndmp-alarm-rule:" + metric.code)
}
if (expression.contains("&&")){
    int num1 = Integer.parseInt(expression.substring(1, expression.indexOf("&&"))); // 提取第一个数字
    int num2 = Integer.parseInt(expression.substring(expression.lastIndexOf("<") + 1)); // 提取第二个数字
    if (num1 >= num2){
        return "表达式编辑错误"
    }
}
return db.update("""
    update alarm_rule set expression = #{expression}, expression_type = #{body.expressionType},
    level = #{body.level},rule_metric_id = #{body.ruleMetricId},rule_name = #{body.ruleName},
    suppress_interval = #{body.suppressInterval},template_content = #{body.templateContent}
    ,unit = #{body.unit}
    where id = #{body.id}
""")